// pages/operat/fleedTools/fleedTools.js
const LApp = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    boundNum: 0,
    storageNum: 0,
    userInfo:{},
    ShowExit:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.YesterdayBound();
    this.YesterdayStorage();
    this.data.userInfo= LApp.globalData.userInfo;
    this.data.wxUserInfo = LApp.globalData.wxUserInfo;
    this.data.ShowExit = this.data.userInfo.RoleID=="Ox8";
    this.setData(this.data);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 昨日出库数量
   */
  YesterdayBound: function () {
    let _this = this;
    LApp._get({
      url: 'nbapi/fleedtool/count/boundcount',
      data: { userId: LApp.globalData.userInfo.UserID },
      success: function (r) {
        _this.setData({
          boundNum: r
        })
      }
    })
  },
  /**
   * 昨日入库数量
   */
  YesterdayStorage: function () {
    let _this = this;
    LApp._get({
      url: 'nbapi/fleedtool/count/storagecount',
      data: { userId: LApp.globalData.userInfo.UserID },
      success: function (r) {
        _this.setData({
          storageNum: r
        })
      }
    })
  },
  /**
   * 窜货统计
   */
  AnfleeCount: function () {

  },
  goOutBank: function () {
    LApp.openView2("outStorage/scanCodes/scanCodes", "nbapi/fleedtool/isoutstorage", LApp.globalData.userInfo.UserID);
  },
  goInBank: function () {
    LApp.openView2("inStorage/scanCode/scanCode", "nbapi/fleedtool/rk/check", LApp.globalData.userInfo.UserID);
  },
  goReturnGoods: function () {
    LApp.openView2("returnGoods/scanCode/scanCode", "nbapi/fleedtool/th/check", LApp.globalData.userInfo.UserID);
  },
  goFillTheBox: function () {
    LApp.openView2("fillThebox/scanCode/scanCode", "nbapi/fleedtool/dh/check", LApp.globalData.userInfo.UserID);
  },
  singleStandard: function () {
    wx.navigateTo({
      url: 'singleStandard/singleStandard',
    })
  },
  goPackBox: function () {
    wx.navigateTo({
      url: 'packBox/packBox',
    })
  },
  gounBoxing: function () {
    LApp.openView2("unBoxing/scanCode/scanCode", "nbapi/fleedtool/db/check", LApp.globalData.userInfo.UserID);
  },
  goantiFleeing: function () {
    wx.navigateTo({
      url: 'antiFleeing/antiFleeing',
    })
  },
  goAntiFake: function () {
    wx.navigateTo({
      url: 'antiFake/antiFake',
    })
  },
  goStorage: function () {
    wx.navigateTo({
      url: 'inStorage/scanCode/scanCode',
    })
  },
  memberInfo: function () {
    //后期放开
    wx.showToast({
      title: '攻城狮正在攻城中...',
      icon:"none"
    })
    // wx.navigateTo({
    //   url: '../../memberInfo/memberInfo',
    // })
  },
  loginOut:function(){
    try {
      wx.clearStorageSync()
    } catch (e) {
      // Do something when catch error
    };
    LApp.globalData.userInfo = undefined;
    wx.reLaunch({
      url: '../../my/logon/guide/guide',
    })
  }
})